package com.ruoyi.project.download;

/**
 * A bean class holds some data of range.
 *
 * @author zw
 */
class Range {

  long start;
  long end;
  long length;


  public Range() {
  }

  public Range(long start, long end, long length) {
    this.start = start;
    this.end = end;
    this.length = length;
  }

  /**
   * Validate range.
   *
   * @return true if the range is valid, otherwise false
   */
  boolean validate() {
    if (end >= length) {
      end = length - 1;
    }
    return (start >= 0) && (end >= 0) && (start <= end) && (length > 0);
  }

}
